﻿namespace KinonekoSoftware.Studio.Galleries
{
    partial class InstanceGalleryViewModel
    {

        private bool   _isLocked;
        private string _name;
        private string _gravatar;
        private string _intro;

        private void WhenSelectedChangedUpdatePropertyBridge()
        {
            if (_selected is null)
            {
                return;
            }

            _isLocked = _selected.IsLocked;
            _name     = _selected.Name;
            _intro    = _selected.Intro;
            _gravatar = _selected.Gravatar;

            RaiseUpdated(nameof(Name));
            RaiseUpdated(nameof(Intro));
            RaiseUpdated(nameof(Gravatar));
            RaiseUpdated(nameof(IsLocked));
            RaiseUpdated(nameof(HasAnyBinding));
        }


        public string Name
        {
            get => _name;
            set
            {
                SetValue(ref _name, value);

                if (Selected is not null)
                {
                    Selected.Name = value;
                }
            }
        }

        public string Gravatar
        {
            get => _gravatar;
            set
            {
                SetValue(ref _gravatar, value);

                if (Selected is not null)
                {
                    Selected.Gravatar = value;
                }
            }
        }

        public string Intro
        {
            get => _intro;
            set
            {
                SetValue(ref _intro, value);

                if (Selected is not null)
                {
                    Selected.Intro = value;
                }
            }
        }

        public bool IsLocked
        {
            get => _isLocked;
            set
            {
                SetValue(ref _isLocked, value);

                if (Selected is not null)
                {
                    Selected.IsLocked = value;
                }
            }
        }
    }
}